#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
	int year = 0;
	int month = 0;
	while(scanf("%d %d", &year, &month)!=EOF)
	{
		if (month != 2)
		{
			if ((month < 8 && (month % 2 == 1)) || (month >= 8 && (month % 2 == 0)))
				printf("%d", 31);
			else
				printf("%d", 30);
		}
		else if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
			printf("%d", 29);
		else
			printf("%d", 28);
		printf("\n");
	}
	return 0;
}